﻿@model List<IdentityServer4.EntityFramework.Entities.ApiResource>
@using IdentityServer4.EntityFramework.Mappers

@{
    ViewBag.Title = "API资源";
    ViewBag.Active = "/apiresource";
    bool isSuperAdmin = (ViewData["IsSuperAdmin"] as bool?) == true;
}
@if (isSuperAdmin)
{
    <el-button class="hx-mb-2" type="primary" @@click="onAdd">添加Api资源</el-button>
}
<el-table :data="tableData" border style="width: 100%" :header-cell-style="{background:'#eef1f6',color:'#606266'}">
    <el-table-column prop="name" label="资源名称" width="120" header-align="center">
    </el-table-column>
    <el-table-column prop="displayName" label="显示名称" width="180" header-align="center">
    </el-table-column>
    <el-table-column prop="userClaims" label="允许的声明" width="200" header-align="center">
        <template slot-scope="scope">
            <span v-html='scope.row.userClaims'></span>
        </template>
    </el-table-column>
    <el-table-column prop="description" label="描述" header-align="center">
    </el-table-column>
    <el-table-column prop="enabled" label="是否启用" width="70" header-align="center">
        <template slot-scope="scope">
            <el-tag :type="scope.row.enabled?'success':'danger'" disable-transitions>
                {{scope.row.enabled? "启用":"禁用"}}
            </el-tag>
        </template>
    </el-table-column>
    <el-table-column fixed="right" label="操作" width="200" v-if="@(isSuperAdmin?"true":"false")" align="center">
        <template slot-scope="scope">
            <el-button size="mini" @@click="onEdit(scope.row)">编辑</el-button>
            <el-button type="danger" size="mini" @@click="handleDelete(scope.row)">删除</el-button>
        </template>
    </el-table-column>
</el-table>
<div class="hx-float-right">
    <el-pagination @@current-change="handleCurrentChange"
                   :current-page.sync="queryParam.pageIndex"
                   :page-size="queryParam.pageSize"
                   background
                   layout="total, prev, pager, next"
                   :total="totalCount">
    </el-pagination>
</div>

<partial name="~/Views/ApiResources/AddOrUpdate.cshtml" />

@section scripts{
    <script src="~/vuejs/apiresources.js"></script>
}

